//
// Created by shen on 2025/3/6.
//

#ifndef VIDEOEDIT_VIDEOGLRENDER_H
#define VIDEOEDIT_VIDEOGLRENDER_H

#include <mutex>
#include <GLES3/gl3.h>
#include "../BaseGLRender.h"
#include "GLUtils.h"
#include "SLog.h"
#include <ImageDef.h>
#include <VideoRender.h>
#define TEXTURE_NUM 3
class VideoGLRender : public BaseGLRender,public VideoRender{
public:
    explicit VideoGLRender();

    ~VideoGLRender() override;

    static VideoGLRender *GetInstance();
    static void ReleaseInstance();

    /**
     * open gl render
     */

    void onDrawFrame() override;
    void onSurfaceChanged(int width, int height) override;
    void onSurfaceCreated() override;


    /**
     * init render data
     */
    void UnInit() override ;
    void RenderVideoFrame(NativeImage *pImage) override;
    void Init(int videoWidth, int videoHeight, int *dstSize) override;

public:
    static VideoGLRender *instance;
    static std::mutex m_Mutex;

    GLuint m_TextureIds[TEXTURE_NUM];
    GLuint m_VboIds[3];
    GLuint m_VaoId;

    NativeImage m_RenderImage;
    /**
     * opengl es
     */
    GLuint m_ProgramObj = GL_NONE;


};


#endif //VIDEOEDIT_VIDEOGLRENDER_H
